package jp.dodododo.dao.util;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import jp.dodododo.dao.exception.SQLRuntimeException;

/**
 * 
 * @author Satoshi Kimura
 */
public abstract class ConnectionUtil {

	public static void close(Connection connection) {
		if (connection == null) {
			return;
		}
		try {
			connection.close();
		} catch (SQLException e) {
			throw new SQLRuntimeException(e);
		}
	}

	public static PreparedStatement prepareStatement(Connection connection, String sql) {
		try {
			return connection.prepareStatement(sql);
		} catch (SQLException e) {
			throw new SQLRuntimeException(e);
		}
	}

	public static DatabaseMetaData getMetaData(Connection connection) {
		try {
			return connection.getMetaData();
		} catch (SQLException e) {
			throw new SQLRuntimeException(e);
		}
	}

}
